package gui;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.BorderFactory;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class TodayEventsPanel extends JPanel {
	private TodayTasksListingPanel todayTasks;
	private static TodayEventsPanel onlyOne;
	
	private TodayEventsPanel() {

		setEnvironment();

		todayTasks = new TodayTasksListingPanel();

		ClockPanel pane = new ClockPanel();
		ClockThread clock = new ClockThread(pane);
		clock.start();

		pane.setPreferredSize(new Dimension(0, 50));
		pane.setOpaque(false);

		add(pane, BorderLayout.NORTH);
		add(todayTasks, BorderLayout.CENTER);
	}
	
	public static TodayEventsPanel getInstanceOf(){
		if(onlyOne == null)
			onlyOne = new TodayEventsPanel();
		return onlyOne;
	}

	private void setEnvironment() {
		setLayout(new BorderLayout());
		setOpaque(false);
		setPreferredSize(new Dimension(50, 350));
		setSize(new Dimension(50, 350));
		setMinimumSize(new Dimension(50, 350));
		setMaximumSize(new Dimension(50, 350));
		setBorder(BorderFactory.createTitledBorder("My Today's Tasks"));
	}

	protected void updateTodayTable(String[][] tasks) {
		todayTasks.updateTodayTable(tasks);
	}
}
